package com.shuan.springboothello.controller;

import com.shuan.springboothello.config.ConfigProperties;
import com.shuan.springboothello.config.PropertiesWithJavaConfig;
import com.shuan.springboothello.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description: <br>
 *
 * @author lu.shuan<br>
 * @date 2021/1/12$<br>
 * @since V1.0<br>
 */
@RestController     // @Controller + @RequestBody
@RequestMapping("/hello")
public class HelloController {

    @Autowired
    private ConfigProperties configProperties;

    @Autowired
    HelloService helloService;

    @RequestMapping("/index")
    public String index() {
        System.out.println(configProperties.getHostname());
        System.out.println(configProperties.getCredentials().getUsername());
        return configProperties.getHostname();
    }

    @GetMapping("/getCountries")
    public String getCountries() {
        String name = helloService.getAllCountries();

        return name;
    }

    @GetMapping
    public String sayHi() {
        return "hello world";
    }


}